package com.bwstudio.demo.consumer.dao;

import java.math.BigDecimal;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.bwstudio.demo.consumer.entity.AccountInfo;

/**
 * @author buwei
 */
@Mapper
@Component
public interface AccountInfoDao extends BaseMapper<AccountInfo>{
	
	@Update("update account_info set account_balance = account_balance + #{amount} where account_no = #{accountNo}")
	int updateAccountBalance(@Param("accountNo") String accountNo, @Param("amount") BigDecimal amount);

	@Select("select count(1) from de_duplication where tx_no = #{txNo}")
	int isExistTx(String txNo);

	@Insert("insert into de_duplication values(#{txNo},now());")
	int addTx(String txNo);

}